/*
* $Id: Factories.cpp 2 2009-12-23 13:58:02Z volok-aleksej@yandex.ru $
*
* Copyright 2008 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "Factories.h"
#include "Settings/DinIntDefined.h"
#include "Settings/sWindow.h"
#include "Validate.h"
#include "Controls.h"

IControl* CControlFactory::CreateControl(sWindow* pWindow, CWnd* pParent, int nId){
	CControl* pControl;
	if(pWindow->m_window.m_strType == STATIC)
		pControl = new CStaticControl(pWindow->m_window.m_strId, pWindow->m_strState, pWindow->m_aParameters);
	if(pWindow->m_window.m_strType == BUTTON_ELEMENT)
		pControl = new CButtonControl(pWindow->m_window.m_strId, pWindow->m_strState, pWindow->m_aParameters);
	if(pWindow->m_window.m_strType == CHECK_BOX)
		pControl = new CCheckBoxControl(pWindow->m_window.m_strId, pWindow->m_strState, pWindow->m_aParameters);
	if(pWindow->m_window.m_strType == EDIT)
		pControl = new CEditControl(pWindow->m_window.m_strId, pWindow->m_strState, pWindow->m_aParameters);
	if(pWindow->m_window.m_strType == EDIT_NUMBER)
		pControl = new CEditNumberControl(pWindow->m_window.m_strId, pWindow->m_strState, pWindow->m_aParameters);
	if(pWindow->m_window.m_strType == EDIT_DOUBLE)
		pControl = new CEditDoubleControl(pWindow->m_window.m_strId, pWindow->m_strState, pWindow->m_aParameters);
	if(pWindow->m_window.m_strType == COMBO_BOX)
		pControl = new CComboBoxControl(pWindow->m_window.m_strId, pWindow->m_strState, pWindow->m_aParameters);
	if(pWindow->m_window.m_strType == LIST_BOX)
		pControl = new CListBoxControl(pWindow->m_window.m_strId, pWindow->m_strState, pWindow->m_aParameters);
	if(pWindow->m_window.m_strType == DATE_CTRL)
		pControl = new CDateTimeControl(pWindow->m_window.m_strId, pWindow->m_strState, pWindow->m_aParameters);
	pControl->CreateControl(pWindow->m_window.m_nX, pWindow->m_window.m_nY, pWindow->m_window.m_nCX,
		pWindow->m_window.m_nCY, pWindow->m_window.m_nStyle,
		pWindow->m_window.m_strCaption, pParent, nId);
	return pControl;
}

IValidate* CValidateFactory::CreateValidate(const std::tstring& strType, const std::tstring& strValue){
	IValidate* pValidate = NULL;
	if(strType == SYMBOL_VALID)
		pValidate = new CSimbolsValidate(strValue);
	if(strType == VALUE_VALID)
		pValidate = new CValueValidate(strValue);
	return pValidate;
}